  import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },
  {
    path: '/account',
    component: Layout,
    redirect: '/account',
    name: 'Nested',
    meta: {
      title: '用户管理',
      icon: 'nested'
    },
    children: [
      {
        path: 'member',
        component: () => import('@/views/account/member/index'), // Parent router-view
        name: 'Member',
        meta: { title: '会员列表' }
      },
      {
        path: `detail/:id`,
        component: () => import('@/views/account/member/detail'), // Parent router-view
        name: 'Detail',
        meta: { title: '会员详情' },
        hidden: true
      },
      {
        path: `edit/:id`,
        component: () => import('@/views/account/member/edit'), // Parent router-view
        name: 'Edit',
        meta: { title: '编辑' },
        hidden: true
      },
      {
        path: 'level',
        component: () => import('@/views/account/level/index'),
        meta: { title: '会员等级' }
      },
      {
        path: `levelAdd`,
        component: () => import('@/views/account/level/add'), // Parent router-view
        name: 'LevelAdd',
        meta: { title: '增加会员等级' },
        hidden: true
      },
      {
        path: `levelEdit/:id`,
        component: () => import('@/views/account/level/add'), // Parent router-view
        name: 'LevelEdit',
        meta: { title: '编辑会员等级' },
        hidden: true
      },
      {
        path: 'memberCard',
        component: () => import('@/views/account/card/index'),
        meta: { title: '会员卡' }
      },
      {
        path: 'card',
        component: () => import('@/views/account/card/card'),
        meta: { title: '设置会员卡信息' },
        hidden: true
      },
      {
        path: 'cardEdit/:id',
        component: () => import('@/views/account/card/add'),
        meta: { title: '编辑会员卡' },
        hidden: true
      },
      {
        path: 'cardAdd',
        component: () => import('@/views/account/card/add'),
        meta: { title: '编辑会员卡' },
        hidden: true
      },
      {
        path: 'coach',
        component: () => import('@/views/account/coach/index'),
        meta: { title: '教练列表' }
      },
      {
        path: 'coachDetail/:id',
        component: () => import('@/views/account/coach/detail'),
        meta: { title: '教练详情列表' },
        hidden: true
      },
      {
        path: `coachAdd`,
        component: () => import('@/views/account/coach/add'), // Parent router-view
        name: 'LevelEdit',
        meta: { title: '编辑教练' },
        hidden: true
      },
      {
        path: `coachEdit/:id`,
        component: () => import('@/views/account/coach/add'), // Parent router-view
        name: 'LevelEdit',
        meta: { title: '编辑教练' },
        hidden: true
      },

    ]
  },
  {
    path: '/goods',
    component: Layout,
    redirect: '/goods/list',
    name: 'Goods',
    meta: { title: '商品', icon: 'goods' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/goods/index'),
        meta: { title: '商品列表', icon: 'table' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/goods/add'),
        meta: { title: '添加', icon: 'tree' },
        hidden: true
      },
      {
        path: 'edit/:id',
        name: 'Edit',
        component: () => import('@/views/goods/add'),
        meta: { title: '修改', icon: 'tree' },
        hidden: true
      }
    ]
  },
  {
    path: '/sort',
    component: Layout,
    redirect: '/sort/list',
    name: 'Sort',
    meta: { title: '商品分类', icon: 'example' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/sort/index'),
        meta: { title: '商品分类', icon: 'table' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/sort/add'),
        meta: { title: '添加', icon: 'list' },
        hidden: true
      }
    ]
  },

  {
    path: '/league',
    component: Layout,
    redirect: '/league/list',
    name: 'League',
    meta: { title: '团课管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/league/index'),
        meta: { title: '团课列表', icon: 'table' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/league/add'),
        meta: { title: '添加', icon: 'table' },
        hidden: true
      },
      {
        path: 'edit/:id',
        name: 'Edit',
        component: () => import('@/views/league/add'),
        meta: { title: '修改', icon: 'table' },
        hidden: true
      },
      {
        path: 'card/:id',
        name: 'Card',
        component: () => import('@/views/league/card'),
        meta: { title: '支持会员卡', icon: 'table' },
        hidden: true
      },
    ]
  },

  {
    path: '/privateCourses',
    component: Layout,
    redirect: '/privateCourses/list',
    name: 'PrivateCourses',
    meta: { title: '私教课程管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/privateCourses/index'),
        meta: { title: '私课课程', icon: 'table' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/privateCourses/add'),
        meta: { title: '添加课程', icon: 'table' },
        hidden: true
      },
      {
        path: 'edit/:id',
        name: 'Edit',
        component: () => import('@/views/privateCourses/add'),
        meta: { title: '编辑私课', icon: 'tree' },
        hidden: true
      },
      {
        path: 'schedule/:id',
        name: 'Schedule',
        component: () => import('@/views/privateCourses/classSchedule'),
        meta: { title: '私课排期', icon: 'tree' },
        hidden: true
      },
      {
        path: 'timeTable',
        name: 'TimeTable',
        component: () => import('@/views/privateCourses/timeTable'),
        meta: { title: '私课课程表', icon: 'tree' },
        hidden: true
      }

    ]
  },
  {
    path: '/order',
    component: Layout,
    redirect: '/order/List',
    name: 'order',
    meta: { title: '订单管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/order/index'),
        meta: { title: '订单信息', icon: 'table' }
      },
      {
        path: 'edit/:orderId',
        name: 'Edit',
        component: () => import('@/views/order/add'),
        meta: { title: '订单详细信息', icon: 'table' },
        hidden: true
      }
    ]
  },

  {
    path: '/gym',
    component: Layout,
    redirect: '/gym/table',
    name: 'Gym',
    meta: { title: '场馆管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/gym/index'),
        meta: { title: '场馆列表', icon: 'table' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/gym/add'),
        meta: { title: '添加', icon: 'tree' },
        hidden: true
      },
      {
        path: 'edit/:id',
        name: 'Edit',
        component: () => import('@/views/gym/add'),
        meta: { title: '编辑', icon: 'tree' },
        hidden: true
      },

    ]
  },
  {
    path: '/book',
    component: Layout,
    redirect: '/book/table',
    name: 'Book',
    meta: { title: '预约管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/book/index'),
        meta: { title: '团课预约列表', icon: 'table' }
      },
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
